package com.syj.collect.app;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.RequiresApi;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.syj.collect.adapter.MFragmentPagerAdapter;
import com.syj.collect.base.BaseActivity;
import com.syj.collect.base.BaseFragment;
import com.syj.collect.fragment.AllFragment;
import com.syj.collect.fragment.CheckedFragment;
import com.syj.collect.fragment.SubmitFragment;
import com.syj.collect.fragment.UnCheckedFragment;
import com.syj.collect.model.LoginActivity;

import java.util.ArrayList;
import java.util.List;


public class AllActivity extends BaseActivity {
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private List<BaseFragment> fList = new ArrayList<>();

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_all);
        tabLayout = findViewById(R.id.tl_tabs);

        viewPager = findViewById(R.id.vp_content);
        if (fList.isEmpty()) {
            fList.add(new AllFragment());
            fList.add(new SubmitFragment());
            fList.add(new CheckedFragment());
            fList.add(new UnCheckedFragment());
        }
        MFragmentPagerAdapter pagerAdapter = new MFragmentPagerAdapter(this.getSupportFragmentManager(), fList);
        viewPager.setAdapter(pagerAdapter);
        viewPager.setOffscreenPageLimit(4);
        tabLayout.setupWithViewPager(viewPager);
    }


    public void StartAction() {
        Intent intent = new Intent(this, LoginActivity.class);
        this.startActivity(intent);

    }


}
